//
//  ALPS_CollectionViewHeader5Item.m
//  Alps
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_CollectionViewHeader5Item.h"

@implementation ALPS_CollectionViewHeader5Item

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        
        self.itemIcon = [[UIImageView alloc] init];
        [self addSubview:_itemIcon];
        
        _itemIcon.backgroundColor = [UIColor grayColor];
        _itemLabel.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.000];
        
        self.itemLabel = [[UILabel alloc] init];
        [self addSubview:_itemLabel];
        _itemLabel.textAlignment = 1;
        _itemLabel.font = [UIFont systemFontOfSize:14];
        
        // 背景颜色
        self.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.000];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.itemIcon makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.left).offset(5);
        make.top.equalTo(self.top).offset(5);
        make.right.equalTo(self.right).offset(-5);
        make.height.equalTo((ScreeWidth / 5.0) - 10);
    }];
    
    [self.itemLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.itemIcon.bottom).offset(5);
        make.height.equalTo(25);
        make.left.and.right.equalTo(self.itemIcon);
    }];
}

- (void)setModel:(ALPS_ClassifyModel *)model
{
    self.itemLabel.text = model.title;
    [self.itemIcon sd_setImageWithURL:[NSURL URLWithString:model.coverPath]];
}

@end
